// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   toUtf8String.java

package include.nseer_cookie;


public class toUtf8String
{

	public toUtf8String()
	{
	}

	public static String utf8String(String s)
	{
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.length(); i++)
		{
			char c = s.charAt(i);
			if (c >= 0 && c <= '\377')
			{
				sb.append(c);
			} else
			{
				byte b[];
				try
				{
					b = Character.toString(c).getBytes("utf-8");
				}
				catch (Exception ex)
				{
					ex.printStackTrace();
					b = new byte[0];
				}
				for (int j = 0; j < b.length; j++)
				{
					int k = b[j];
					if (k < 0)
						k += 256;
					sb.append((new StringBuilder("%")).append(Integer.toHexString(k).toUpperCase()).toString());
				}

			}
		}

		return sb.toString();
	}
}
